package service;

import dao.UserDao;
import dao.UserDaoImpl;
import entity.User;

import java.util.List;

public class UserServiceImpl implements UserService{
    //调用DAO对象
    private UserDao userDAO = new UserDaoImpl();

    @Override
    public User login(String username, String password) {
        // 调用DAO对象，通过用户名查询用户
        User user = userDAO.selectUserByUsername(username);
        // 判断用户是否存在，并且密码是否正确
        if(user != null){
            if(password.equals(user.getPassword())){
                return user;
            }
        }
        return null;
    }

    @Override
    public List<User> findAllUsers() {
        return userDAO.selectAllUsers();
    }
}
